#include "Lambertian.hpp"
#include "ShadePayload.hpp"
#include "Ray.hpp"

bool Lambertian::scatter(
    const Ray& rayIn, const ShadePayload& payload,
    Ray& rayOut, Eigen::Vector3f& attenuation
)const {
    Eigen::Vector3f sctDir = rand_vec_in_sphere() + payload.normal;
    if (sctDir.norm() < 0.01) {
        sctDir = payload.normal;
    }
    else {
        sctDir.normalize();
    }
    rayOut = Ray(payload.pos, sctDir);
    attenuation = albedo;
    return true;
}